package com.yiqi.zhiyuan.feature.certification.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.zhiyuan.entity.dto.DiverCertificationDTO;
import com.yiqi.zhiyuan.entity.vo.CertufucateInfoVO;
import com.yiqi.zhiyuan.feature.certification.contract.CertificationContract;
import com.yiqi.zhiyuan.feature.certification.dependencies.certification.DaggerCertificationModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.UserApi;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CertificationModel implements CertificationContract.Model {
    @Inject
    UserApi api;

    public CertificationModel() {
        DaggerCertificationModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }

    @Override
    public Observable<String> doUploadInfo(DiverCertificationDTO diverCertificationDTO) {
        return api.uploadInfo(diverCertificationDTO).compose(RxDataProcessFactory.<String>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<CertufucateInfoVO> doQueryAuthInfo() {
        return api.queryAuthInfo().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}

